package com.example.task1.ui.AllService.pet;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.example.task1.R;
import com.example.task1.bean.PetChattingBean;
import com.example.task1.ui.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

public class ChattingAdapter extends BaseAdapter<PetChattingBean.RowsBean> {
    private TextView tvText;

    private Context mContext;
    private List<PetChattingBean.RowsBean> data = new ArrayList<>();

    public ChattingAdapter(Context context) {
        mContext = context;
    }

    public void setData(List<PetChattingBean.RowsBean> rows){
        int size = data.size();
        data.addAll(rows);
        notifyItemInserted(size);
    }

    @Override
    protected int getLayout() {
        return R.layout.textview;
    }

    @Override
    protected Context getContext() {
        return mContext;
    }

    @Override
    protected List<PetChattingBean.RowsBean> getData() {
        return data;
    }

    @Override
    protected void onBind(myHolder holder, PetChattingBean.RowsBean date) {
        tvText.setText(date.getContent());
    }

    @Override
    protected void holder(View itemView) {
        initView(itemView);
    }

    private void initView(View itemView) {
        tvText = itemView.findViewById(R.id.tv_text);
    }
}
